package cn.liweixi.test;

import org.junit.Test;
import redis.clients.jedis.Jedis;

public class testJedis {
    @Test
    public void test01() throws Exception{
        //创建连接
        String host ="127.0.0.1";
        //端口
        int port = 6379;
        //超时时间,1秒超时
        int timeout = 1000;
        //jedis客户端
        Jedis jedis = new Jedis(host,port,timeout);
        //认证
        jedis.auth("123456");
        //执行操作,保存值
        jedis.set("username","lichungang");
        //获取值
        String result = jedis.get("username");
        System.out.print(result);
        //关闭连接
        jedis.close();
    }
}
